package com.einmeer.kssc_administrator.controller;

import com.einmeer.kssc_administrator.entity.Instructor;
import com.einmeer.kssc_administrator.service.InstructorService;
import com.einmeer.kssc_administrator.vo.ResultVo;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

/**
 * @author 芊嵛
 * @date 2024/2/1
 */
@RestController
@RequestMapping("/instructor")
public class InstructorController {
    @Resource
    private InstructorService instructorService;

    /**
     * 查询指导老师全部信息
     *
     * @return
     */
    @GetMapping("/instructorAllInfo")
    @CrossOrigin
    public ResultVo instructorAllInfo() {
        return instructorService.instructorAllInfo();
    }

    /**
     * 添加指导老师根据姓名、学校、工号、职务、电话
     *
     * @param instructor
     * @return
     */
    @PostMapping("/addInstructorInfo")
    @CrossOrigin
    public ResultVo addInstructorInfo(@RequestBody Instructor instructor) {
        return instructorService.addInstructorInfo(instructor.getInstructorName(), instructor.getInstructorSchool(), instructor.getInstructorJobNumber(), instructor.getInstructorPosition(), instructor.getInstructorPhone());
    }

    /**
     * 删除指导教师，实际修改删除标记
     *
     * @param instructor
     * @return
     */
    @RequestMapping("/deleteInstructorById")
    @CrossOrigin
    public ResultVo deleteInstructorById(@RequestBody Instructor instructor) {
        return instructorService.deleteInstructorById(instructor);
    }

    /**
     * 修改指导老师信息
     *
     * @param instructor
     * @return
     */
    @RequestMapping("/changeInstructorInfo")
    @CrossOrigin
    public ResultVo changeInstructorInfo(@RequestBody Instructor instructor) {
        return instructorService.changeInstructorInfo(instructor);
    }

    /**
     * 查询出一条指导老师
     *
     * @param instructorId
     * @return
     */
    @GetMapping("/queryOneInstructor")
    @CrossOrigin
    public ResultVo queryOneInstructor(@RequestParam(value = "instructorId") Long instructorId) {
        return instructorService.queryOneInstructor(instructorId);
    }

    /**
     * 模糊查询根据姓名和工号
     *
     * @param instructor
     * @return
     */
    @GetMapping("/queryLikeInstructor")
    @CrossOrigin
    public ResultVo queryLikeInstructor(Instructor instructor) {
        return instructorService.queryLikeInstructor(instructor.getInstructorName(), instructor.getInstructorJobNumber(),instructor.getInstructorPhone());
    }

}
